﻿<?php
require_once("admin-header.php");
require_once("../maincore.php");
if (!defined("THNOJ")) die ("Outside of the site");

        @session_start();
        require_once("../include/db_info.inc.php");
  $cache_time=2;
        //require_once("../include/cache_start.php");
        
require_once("../include/my_func.inc.php");
require_once("../include/db_info.inc.php");
if(isset($OJ_LANG)){
                require_once("../lang/$OJ_LANG.php");
        }
require_once("../include/const.inc.php");

?>


<meta http-equiv='refresh' content='60'>
<title>Kết quả nộp bài</title>
<center>

<?php 

$str2="";

$sql="SELECT * FROM `solution` WHERE 1 ";
if (isset($_GET['cid'])){
	$cid=intval($_GET['cid']);
	$sql=$sql." AND `contest_id`='$cid' and user_id='$myid' ";
	$str2=$str2."&cid=$cid";
}else{
	$sql=$sql." and user_id='$myid' ";
}
?>
<h1>Kết quả:</h1>
<table align=center>
<tr  class='toprow'>
<td >Mã
<td >Thí sinh
<td >Bài toán
<td >Kết quả
<td >Bộ nhớ
<td >Thời gian
<td >NNLT
<td >Độ dài
<td >Nộp lúc
<td> Nhận xét
</tr>
<?php 


//$sql=$sql.$order_str." LIMIT 40";
$sql="select * from solution where ((contest_id in (select contest_id from contest where author_id='$myid')) or (problem_id in (select problem_id from problem where author_id='$myid')))".(isset($cid)?" and contest_id=$cid":"").(isset($_GET['user'])?" and user_id='".$_GET['user']."'":"").(isset($_GET['pid'])?" and problem_id=".$_GET['pid']:"").(isset($_GET['rate'])?" and pass_rate>=".$_GET['rate']:"")." order by ".(isset($cid)?"problem_id desc,":"")."in_date desc";
//echo $sql;

$result = mysql_query($sql) or die("Error2! ".mysql_error());
$rows_cnt=mysql_num_rows($result);

$top=$bottom=-1;
$cnt=0;
if ($start_first){
        $row_start=0;
        $row_add=1;
}else{
        $row_start=$rows_cnt-1;
        $row_add=-1;
}



for ($i=0;$i<$rows_cnt;$i++){
if($OJ_MEMCACHE)
	$row=$result[$i];
else
	$row=mysql_fetch_array($result);
	if ($top==-1) $top=$row['solution_id'];
	$bottom=$row['solution_id'];
	if ($cnt) echo "<tr align=center class='oddrow'>";
	else echo "<tr align=center class='evenrow'>";
	$flag=true;

	$cnt=1-$cnt;

	echo "<td>".$row['solution_id'];
	echo "<td><a href='../userinfo.php?user=".$row['user_id']."'>".$row['user_id']."</a>";

	//if (isset($cid)) 
		//echo "<td><a href='../problem.php?cid=$cid&pid=".$row['problem_id']."'>".$row['problem_id']."</a>";
	//else 
		echo "<td><a href='../problem.php?id=".$row['problem_id']."'>".$row['problem_id']."</a>";
	
	if (intval($row['result'])==11){
		echo "<td><a href='../ceinfo.php?sid=".$row['solution_id']."' class=".$judge_color[$row['result']].">".$judge_result[$row['result']]."</a>";
	} else if (intval($row['result'])==10){
		echo "<td><a href='../reinfo.php?sid=".$row['solution_id']."' class=".$judge_color[$row['result']].">".$judge_result[$row['result']]."</a>";
	} else {
		echo "<td class=".$judge_color[$row['result']].">".($OJ_OI_MODE&&(($row['result']==6)||($row['result']==4))?round($row['pass_rate']*100,2)."%":$judge_result[$row['result']]);	
	}
	if ($flag){
		if ($row['result']>=4){
				echo "<td class=red>".$row['memory'];
				echo "<td class=red>".$row['time'];
		}else{
				echo "<td>------<td>------";
		}
		//if (!(isset($_SESSION['user_id'])&&strtolower($row['user_id'])==strtolower($_SESSION['user_id']) || isset($_SESSION['source_browser']))){
				//echo "<td>".$language_name[$row['language']];
		echo "<td><a href=../bai.php?id=".$row['solution_id'].">".$language_name[$row['language']]."</a>";
		
		echo "<td>".$row['code_length']." B";
	} else echo "<td>------<td>------<td>".$language_name[$row['language']]."<td>------";
	echo "<td>".$row['in_date'];
	echo "<td>".$row['comment']."";
	echo "</tr>\n";
}
mysql_free_result($result);
?>
</table>
<?php echo "[<a href=status.php?".$str2.">Top</a>]&nbsp;&nbsp;";
if (isset($_GET['prevtop']))
        echo "[<a href=status.php?".$str2."&top=".$_GET['prevtop'].">Previous Page</a>]&nbsp;&nbsp;";
else
        echo "[<a href=status.php?".$str2."&top=".($top+20).">Previous Page</a>]&nbsp;&nbsp;";
echo "[<a href=status.php?".$str2."&top=".$bottom."&prevtop=$top>Next Page</a>]";
?>

<?php require_once("../oj-footer.php");?>
<?php //require_once("../include/cache_end.php");?>
